package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {
    public static void main(String[] args)throws Exception {
        Class cls=Class.forName("reflect.Person");
        Method m=cls.getMethod("say",String.class,int.class);
        String name=m.getName();
        System.out.println("方法名："+name);
        Class returnType=m.getReturnType();
        System.out.println("返回值类型："+returnType);
        Class[] parameterTypes=m.getParameterTypes();
        for(Class c:parameterTypes){
            System.out.println("参数类型："+c);
            int modifiers=m.getModifiers();
            switch (modifiers){
                case Modifier.PUBLIC:
                    System.out.println("访问修饰符:public");
                    break;
                    case Modifier.PRIVATE:
                        System.out.println("访问修饰符:private");
                        break;
                    case Modifier.PROTECTED:
                            System.out.println("访问修饰符:protected");
                            break;
                    case Modifier.STATIC:
                                System.out.println("访问修饰符:static");
                                break;
            }
        }
    }
}
